﻿using FreedomX2.Core.Dynamic.Load;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FreedomX2.Core.IO;
using FreedomX2.Core.Dynamic.Compiler;
using FreedomX2.Core.Log;
using FreedomX2.Core;
namespace FreedomX2.Temp.ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "abc1.esdf2.els3.dksl4.dsf5.sdf6".SplitBy('.', 3, ABSet.After);
            //result: dksl4.dsf5.sdf6
            string s1 = @"http://msn.ynet.com/1183/2013/01/23/349@405235.htm";
            string s2 = s1.SplitBy('/', 4, ABSet.After).SplitBy('/', -1, ABSet.Before);
            //result: 2013/01/23
            string s3 = s1.SplitBy('.', -1, ABSet.After);
            //result: htm
            "我是日志，自动的".l();

            var ittest2 = Loader.SInvokeDLLFun(@"\a\FreedomX2.Temp.ConsoleApplication1.exe;FreedomX2.Temp.test.getnn", "哈哈", "嘿嘿");
            var itest3 = Loader.SInvokeDLLMem(@"\a\FreedomX2.Temp.ConsoleApplication1.exe;FreedomX2.Temp.test.haha");
            Loader load = new Loader(@"\a\FreedomX2.Temp.ConsoleApplication1.exe", "FreedomX2.Temp.test");
            var itet = load.InvokeDLLFun("getnn", "嘿嘿", "吼吼");
            var s3241 = (load.LastType as Type).GetMethod("getnn").Invoke(load.LastInstance, new object[] { "次次", "嗷嗷" });
            object obj = null;
            obj = load.InvokeDLLPubVars(null);
            (obj as List<object>).Add(new DateTime().AddYears(100));
            load.InvokeDLLPubVars(obj);
            object obj3 = load.InvokeDLLPubVars(null);
            object obj2 = null;
            obj2 = load.InvokeDLLMem("haha", null);
            load.InvokeDLLMem("haha", "cicicicici");









            string source = @"
    using System;
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine(""已经注册Asp.Net IIS服务器"");
            Console.ReadLine();
        }
        public string nihao(){
            return ""hahaha"";
        }
    }";
            var comerr = Coder.CompilerFromCode("C:\\aaa.dll",
                new string[] { source },
                mainClass: "Program",
                CompilerVersion: "v4.0");
            if (comerr.Length == 0)
            {
                var va = Loader.SInvokeDLLFun(@"C:\\aaa.dll;Program.nihao", null);
            }
        }
    }
}
